package sf.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import sf.dao.inf.EmailInf;
import sf.dao.pojo.TEmail;

public class EmailImpl extends HibernateDaoSupport implements EmailInf {

	public Serializable add(TEmail tEmail) {
		Serializable i = getHibernateTemplate().save(tEmail);
		return i;
		
	}

	public void update(TEmail tEmail) {
		getHibernateTemplate().update(tEmail);
		getSession().beginTransaction().commit();
	}
	
	public TEmail get(int nemailid) {
		TEmail tEmail = getHibernateTemplate().get(TEmail.class, nemailid);
		return tEmail;
	}
	
	public void delete(int nemailid) {
		TEmail tEmail = get(nemailid);
		delete(tEmail);
	}

	public void delete(TEmail tEmail) {
		getHibernateTemplate().delete(tEmail);
	}

	public List<TEmail> findAllEmails() {
		String hql = "from TEmail";
		List<TEmail> emailList = getHibernateTemplate().find(hql);
		return emailList;
	}


}
